<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>微信安全支付</title>
<%@ include file="../common/common.jsp"%>
<script type="text/javascript">
	var jspay = ${jspay};
	var orderNo = '${orderNo}';
	function onBridgeReady(){
		// 接收后台传递过来的支付串
		//调用微信支付JS接口
		WeixinJSBridge.invoke('getBrandWCPayRequest', jspay, function(res) {
			if (res.err_msg == 'get_brand_wcpay_request:ok') {
				// 支付已完成！,注意这里支付完成指的是前端JS发起支付的操作顺利完成，
				//并不意味着真正的支付成功，强烈建议到支付回调中去校验支付成功与否。
				//alert("支付成功,地址:"+mServerUrl+"/page/paySuccess.htm?orderNo="+orderNo);
				window.location.href=mServerUrl+"/page/softBuyPage.htm";
				WeixinJSBridge.call('closeWindow');
			} else if (res.err_msg == 'get_brand_wcpay_request:fail') {
				// 支付出现问题，请稍后再试！
				alert("支付出现问题，请稍后再试！");
			} else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
				// 已取消支付，请重新支付！
				alert("您已取消支付！");
				window.location.href=mServerUrl+"/page/softBuyPage.htm";
				//WeixinJSBridge.call('closeWindow');
			} else {
				// 支付被拒绝了
				alert("支付被拒绝了");
			}
		}); 
	}
	if (typeof WeixinJSBridge == "undefined"){
	   if( document.addEventListener ){
	       document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
	   }else if (document.attachEvent){
	       document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
	       document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
	   }
	}else{
	   onBridgeReady();
	}
</script>
</head>
<body>

</body>
</html>